//
//  XDSearchBar.m
//  HengHuaSupervision
//
//  Created by XD-XY on 3/21/14.
//  Copyright (c) 2014 XD-XY. All rights reserved.
//

#import "XDSearchBar.h"
#import "XDHeader.h"
#import <QuartzCore/QuartzCore.h>
@implementation XDSearchBar

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
        self.backgroundColor = [UIColor whiteColor];
        [self makeView];
    }
    return self;
}

-(void)makeView
{
    self.searchBar = [[UISearchBar alloc] initWithFrame:self.bounds];
    //_searchBar.searchBarStyle = UISearchBarStyleDefault;
    
    float version = [[[UIDevice currentDevice] systemVersion] floatValue];
    if ([_searchBar respondsToSelector:@selector(barTintColor)]) {
        float iosversion7_1 = 7.1;
        if (version >= iosversion7_1)
        {
            //iOS7.1
            [[[[_searchBar.subviews objectAtIndex:0] subviews] objectAtIndex:0] removeFromSuperview];
            [_searchBar setBackgroundColor:[UIColor clearColor]];
        }
        else
        {
            //iOS7.0
            [_searchBar setBarTintColor:[UIColor clearColor]];
            [_searchBar setBackgroundColor:[UIColor clearColor]];
        }
    }
    else
    {
        //iOS7.0以下
        [[_searchBar.subviews objectAtIndex:0] removeFromSuperview];
        [_searchBar setBackgroundColor:[UIColor clearColor]];
    }
    [self addSubview:_searchBar];
    
    
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
    // Drawing code
}
*/

@end
